#include "stdafx.h"
#include "Player.h"
#include "Spell.h"
#include "DirectInput.h"
#include "Camera.h"

Player::Player()
{

}

Player::~Player()
{

}

void Player::Init()
{
	this->m_fMana = 5.0f;
	this->m_fManaRegenRate = 2.0f;
	this->m_fMaxMana = 20.0f;
	this->m_nHealth = 100;

	m_vSpells.clear(); //
}

void Player::Update(float _dt)
{
	if(m_fMana < m_fMaxMana)
	{
		m_fMana += (m_fManaRegenRate * _dt);

		if(m_fMana > m_fMaxMana)
			m_fMana = m_fMaxMana;
	}
	
	D3DXVECTOR3 right = CCamera::GetInstance()->m_right;
	D3DXVECTOR3 look = CCamera::GetInstance()->m_look;
	DirectInput* pInput = DirectInput::GetInstance();
	//left
	if(pInput->KeyDown(DIK_A))
	{
		m_Position.x -= right.x * (_dt*CAMERA_SPEED);
		m_Position.y -= right.y * (_dt*CAMERA_SPEED);
		m_Position.z -= right.z * (_dt*CAMERA_SPEED);
	}
	//right
	if(pInput->KeyDown(DIK_D))
	{
		m_Position.x += right.x * (_dt*CAMERA_SPEED);
		m_Position.y += right.y * (_dt*CAMERA_SPEED);
		m_Position.z += right.z * (_dt*CAMERA_SPEED);
	}
	//Down
	if(pInput->KeyDown(DIK_S))
	{
		m_Position.x += look.x * (_dt*CAMERA_SPEED);
		m_Position.y += look.y * (_dt*CAMERA_SPEED);
		m_Position.z += look.z * (_dt*CAMERA_SPEED);
	}
	//Up
	if(pInput->KeyDown(DIK_W))
	{
		m_Position.x -= look.x * (_dt*CAMERA_SPEED);
		m_Position.y -= look.y * (_dt*CAMERA_SPEED);
		m_Position.z -= look.z * (_dt*CAMERA_SPEED);
	}
}

void Player::Render()
{

}
